frm256PicBx &256 Color VB Picture Box Demonstration Form1, Label1 Current Directory: labDirSelected pbCancel E&XIT Label2 &Directories Label3 &Bitmap Files R lbDirList lbFileList *.bmp PicPreview PicPreviewVScroll Label4 D&rives cbDrives W pbPreview &Preview PicPreviewHScroll PicScrollBarFiller PicPreviewSource hDIBUtilG hPalette hDIBBuffer lpDIBBuffer[ Form_Load OldMousePtr Screen MousePointer HOURGLASS Set_ModalDlg_SysMenu frm256PicBxm StartingDir labDirSelected Captiont cbDrives Drive lbDirList Path~ SBColors GetProfileInfom PicScrollbarFiller BackColor LoadLibrary NULL. lbDirList_Change lbFileList pbCancel_Click^ cbDrives_Change lbFileList_DblClickT pbPreview_Click lbFileList_PathChange ListIndexd SrcXm DestXC DestY bmpWidth& bmpHeight ShowFiller PicPreview Picture| PicPreviewSource ListCount) FastExitW FName ListQ DIBLoad3 GlobalLock DIBWidth DIBHeight ReturnVal GlobalUnlock ScaleWidth DestWidth ScaleHeight{ DestHeight PicPreviewHScrollS Visible FALSE SmallChange LargeChangeA Value PicPreviewVScrollp DeleteObject CreateDIBPalette hOldPalette SelectPalette RealizePalette hBitmap CreateDIBitmap CBM_INIT FindDIBBits DIB_RGB_INFO hCompatDC CreateCompatibleDC hPrevBmp SelectObject Success BitBlt SRCCOPY DeleteDCf GlobalFree MovePic; PicPreviewHScroll_Change PicPreviewVScroll_Changep Form_Unload Cancel FreeLibrary Section KeyName Result ResultLength GetProfileString A_Form HSysMenu GetSystemMenu RemoveMenu MF_BYPOSITION APIError AutoRedraw` Handle to our dll Handle to a palette created for previewing a bitmap Handle to a global memory area into which a DIB file has been read (for use with DIB utility routines) A pointer to the actual memory buffer containing the DIB Form_Load Remove all but Move and Close from the system menu Set up starting directoryl Set the color of the "filler" between scroll barsr Colors ScrollBar" Load the DIBUTIL library" DIBUTIL.DLL" Since we haven't yet created a palette, initialize hPalette tor null to indicate this lbDirList_Change pbCancel_Click cbDrives_Change lbFileList_DblClick lbFileList_PathChange pbPreview_Click Set an hourglass cursor Clear any existing bitmaps Any bitmap files in the listbox? Please select a Bitmap file before pressing the Preview button If no bitmap file is selected, take the first one Load the bitmap into memory and get its dimensions Error loading Set up bitblt parameters Set up the scroll bars If we have previously created a palette, delete it now (pbPreview_Click) Warning: Could not delete hPalette!" Create a new palette for this bitmap Make sure DC containing the persistent image has the right palette Make sure the picture box DC has the right paletteh Lock the memory block Create a Device Dependent Bitmap Create a memory DC from which we can bitblt the image. Select in and realize the palette, then select in the ddb hOldPalette% = SelectPalette(hCompatDC%, hPalette, FALSE)S ReturnVal% = RealizePalette(hCompatDC%), Blast the image into our hidden picture boxa Free up resources we no longer need (pbPreview_Click) Warning: Could not delete hComptDC%! (pbPreview_Click) Warning: Could not delete hBitmap%!" release previously allocated memoryn Now fill in the scrollable picture box Restore the cursor PicPreviewHScroll_Change PicPreviewVScroll_Change Form_Unload if hPalette is not 0 then we've created a palette that" should be deleted before we terminate the program (Form_Unload) Warning: Could not delete hPalette!" Allow Windows to unload our dll GetProfileInfo Set_ModalDlg_SysMenu Obtain the handle to the forms System menu Remove all but the MOVE and CLOSE options. The menu items must be removed starting with the last menu item to prevent the menu items from taking on new position values as othert menu items are being removed. Switch to. Separator. Separator. Maximize Minimize Restoree MovePic Set up bitblt parameters In case anyone has changed the palette since we last painted, realize it (again) Blast the new picture into the preview picture box If the picture box has AutoRedraw on, it must be refreshed